rebotfandomcom-20200214-history
Lua
ReBot Lua API ReBot can now run Lua scripts directly through the quest/script bot. Once started, the script will be run from start to finish without pausing. Any kind of looping/processing will thread-block and there are no native timers available during default execution. In general, you should not do much processing in the global scope for this reason. Once the script has completed execution, the bot will call a function defined as Main() every single tick. If the function returns an integer, the next call will be delayed by that many milliseconds (non thread-blocking). However, if the function returns anything else, the bot will stop calling Main() and exit. Below is an example. -- This code will be executed just once, as soon as the bot is run. local myCount = 0; -- We can register functions for later use. function doTheThing() -- Info() is one of three logging functions: Info(), Warning() and Error(). Info("The thing, it has been done!"); end -- This is our main function that will be called constantly AFTER the entire -- script has finished executing. function Main() if myCount < 5 then myCount = myCount + 1; Info("Count is less than five, waiting five seconds."); return 5000; -- Returning 5000 here will cause the bot to wait 5 seconds. end doTheThing(); -- We can call our previously defined function! return nil; -- Returning a non-number will exit the processing. end -- Despite being after Main(), this will be run before Main() is called. Info("Finished loading!"); Below is a list of all functions that can be used in an Lua script ran in ReBot with extensive documentation for each function. If you need more assistance, contact Renyei on the forums. Combat/Targeting * BanFromCombat * CollectUnits * EntityIsCombatTarget * KillUnits * StartCombat * UnbanFromCombat * SetTargetByID Quests * HasQuest * IsQuestCompleted * IsQuestInLogAndComplete * IsQuestObjectiveComplete Items * CanWearArmorType * DeleteItem * EquipBestItem * EquipItem * GetAutoEquipRating * HasItem * IsItemEquipped * ItemCooldown * ItemCount * UseEquippedItem * UseItem * GetFreeBagSlots * ForceVendorNow Bot Behavior * DisableCombat * DisableFlightPathDiscovery * DisableOutOfCombat * DisableTaxiUsage Navigation/Location * ContinentID * ContinentIDWithoutPhasing * CoordsToPositionByAreaID * CoordsToPositionByZoneID * GetTimeOnContinent * CTM * GetCTMTarget * GetNaviTarget * IsNaviRunning * IsNaviTargetInWater * MoveTo * MoveToStop * CanTraverse * IsInGarrison * SetFacing Spells/Auras/Mounts * HasAura * CancelAura * CastSpell * ClickOnTerrain * HasSpell * SpellCooldown * Dismount * HasMount * SummonMount * MountUp * LearnAllSkillsAtTrainer Utility/Scripting * SwitchScript - Changes which script is currently executing. * SetMain - Change which function will be called each cycle. * StopBot * ExecuteLua * ExecuteMacro * LuaIf * IsInGame * IsInWorld Logging * Info - Logs an informational message to the output log. * Warning - Logs a warning message to the output log. * Error - Logs an error message to the output log. Objects * Me * GetPlayers - Returns all players currently loaded. * GetUnits - Returns all units currently loaded. * GetGameObjects - Returns all game objects currently loaded (doors, benches etc). * GetDynamicObjects - Returns all dynamic objects currently loaded (spell effects etc). Object Types These wrapper objects have been specifically designed to integrate with Lua without casting/marshalling issues. It's highly recommended that you work with these rather than the raw classes. All Lua API functions will return results wrapped in these classes. * LuaGenericObject - Base object; all objects inherit from this. * LuaPlayer - Represents a player in the world. * LuaLocalPlayer - Represents the client's player. * LuaUnit - Represents a unit in the world. * LuaGameObject - Represents a game object in the world (doors, benches etc). * LuaDynamicObject - Represents a dynamic object in the world (spell effects etc). * LuaAIGroup - Represents an AI group. * LuaCorpse - Represents a corpse of a player in the world.